package springinpractice.ch8.mailinglist.service;

import springinpractice.ch8.mailinglist.model.Subscriber;

/*
 * Author       :       Willie Wheeler and John Wheeler
 * Book         :       'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 */

public interface MailingListService {
	
	Subscriber getSubscriber(long id);
	
	/**
	 * <p>
	 * Adds a subscription for the given subscriber. The subscriber must be
	 * unconfirmed. It's fine if there are other subscriptions associated with
	 * the same subscriber. We don't want to complain about it because that
	 * would give attackers a way to discover whether any given e-mail address
	 * is already signed up for the mailing list.
	 * </p>
	 * 
	 * @param subscriber
	 */
	void addSubscriber(Subscriber subscriber);
	
	void confirmSubscriber(long subscriberId, String digest)
		throws ConfirmationFailedException;
	
	/**
	 * <p>
	 * Removes all subscriptions with the given e-mail address.
	 * </p>
	 * 
	 * @param email
	 */
	void requestUnsubscription(String email);
	
	void confirmUnsubscription(String email, long timestamp, String digest)
		throws ConfirmationFailedException;
}
